package com.basin.micro.admin.module.employee.controller;

import com.basin.common.core.response.ResponseResult;
import com.basin.common.mp.base.BaseController;
import com.basin.common.redis.annotation.BasinLock;
import com.basin.micro.admin.module.employee.mapper.EmployeeMapper;
import com.basin.micro.admin.module.employee.pojo.entity.EmployeeEntity;
import com.basin.micro.admin.module.employee.repository.EmployeeRepository;
import com.basin.micro.admin.module.employee.service.EmployeeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
@RestController
@RequestMapping("/employee")
@Slf4j
@RequiredArgsConstructor
public class EmployeeController extends BaseController<EmployeeRepository, EmployeeEntity, EmployeeMapper> {
    private static final String ADD_LOCK_KEY = "employee:addLock";

    private final EmployeeService employeeService;

    @Override
    @BasinLock(key = ADD_LOCK_KEY)
    public ResponseResult<Boolean> add(EmployeeEntity entity) {
        requireValFieldsCheck(entity);
        return ResponseResult.success(employeeService.add(entity));
    }

    @PostMapping("/fillPersonInfo")
    public ResponseResult<Boolean> fillPersonInfo() {
        return ResponseResult.success();
    }
}
